// pages/gongxiu/select/index.js
var app = getApp()
Page({
  /**
   * 页面的初始数据
   */
  data: {
  index:0,
  index2:0,
  index3:0,
  disabled:true,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    wx.request({
      url: 'https://api.bjlya.com.cn/nfq.php/index/Gongxiu/index7', // 仅为示例，并非真实的接口地址
      data: {
        openid:app.openid,
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success(res) {
        console.log(res.data)
        var selected_gongke = res.data.gongke['0']
        var selected_qun = res.data.qun['0'] 

        that.setData({
          gongke: res.data.gongke,
          qun: res.data.qun,  
          date:['今天','昨天'],  
          selected_gongke:selected_gongke,
          selected_qun:selected_qun,
          selected_date:'今天',
        })
      }
    })
  },
  bindPickerChange(e) {
    var index = e.detail.value 
    var selected_gongke = this.data.gongke[index]
    console.log(selected_gongke)
    this.setData({
      index: e.detail.value,
      selected_gongke:selected_gongke,
      disabled:false,
    })
  },
  bindPickerChange2(e) {
    //console.log('picker发送选择改变，携带值为', e.detail.value)
    var index = e.detail.value
    var selected_qun = this.data.qun[index]
    this.setData({
      index2: e.detail.value,
      selected_qun:selected_qun,
      disabled:false,
    })
  },
  bindPickerChange3(e) {
    //console.log('picker发送选择改变，携带值为', e.detail.value)
    var index = e.detail.value
    var selected_date =this.data.date[index]
    this.setData({
      index3: e.detail.value,
      selected_date:selected_date,
      disabled:false,
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  
  primary:function(){
   var gongke = this.data.selected_gongke 
    app.globalData.gongke = gongke
 
   var date = this.data.selected_date
    app.globalData.date = date
   
   var qun = this.data.selected_qun
    app.globalData.qun = qun
  
    wx.switchTab({
      url: "/pages/gongxiu/index"
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})